package bm.com.ai.server.dto;

import bm.com.ai.server.LLModel.constant.ModelType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MessageResponse implements Serializable {
    private static final long serialVersionUID = 1L;

    private String requestId; // 关联的请求ID
    private String content; // 响应内容
    private ModelType modelUsed; // 实际使用的模型
    private LocalDateTime timestamp; // 时间戳
    private long processingTimeMs; // 处理时间（毫秒）
    private boolean isSuccessful; // 是否成功
    private String errorMessage; // 错误信息（如果失败）

    // Token统计信息
    private TokenStats tokenStats;

    // RAG来源信息
    private List<RagSource> ragSources;

    // 附加信息
    private Map<String, Object> metadata;

    @Data
    @Builder
    public static class TokenStats {
        private int promptTokens; // 提示词token数量
        private int completionTokens; // 响应token数量
        private int totalTokens; // 总token数量
    }

    @Data
    @Builder
    public static class RagSource {
        private String id;
        private String content;
        private double similarityScore;
        private String source;
        private Map<String, String> metadata;
    }
}
